package DualRMI;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class RunClient {
	
	private Client connect2Client(){
		Client client = null;
		try {
			client = new Client(InetAddress.getLocalHost(), 1900, 1337);
		} catch (UnknownHostException e) {
			System.out.println("Could not find your local host address");
			e.printStackTrace();
		}
		return client;
	}
	
	
	public RunClient(){
		System.setSecurityManager(new LiberalSecurityManager());
		
		System.out.println("Starting Client");
		Client client = connect2Client();
		if (client == null){
			System.out.println("No connection.\nProgram end");
			return;
		}
		
		RemoteInterface ro = client.getRIObject();
		try {
			ro.print("This is a test");
		} catch (RemoteException e) {
			System.out.println("Something went wrong with the printing");
			e.printStackTrace();
		}
	}
	public static void main(String[] args){
		RunClient runningCleint = new RunClient();
	}
}
